Skip to main content
Version: Next

getRuntimeCb

This method calculates the execution time of async functions and returns the execution time to you in the form of a callback

Params

getRuntimeCb(inputFunction,cb);
  • inputFunction → This input is a function. The function whose execution time will be calculated
  • cb → A function that will be called as a callback and the output will be passed to this function
Take care

When you use this method, be sure to define the callback function

Returns

cb(err,runtime){
//codes
}
  • err → In case of any problem that causes this method to not be able to calculate the execution time, it will return the error in this parameter.
  • runtime → The execution time of the function is placed in this parameter

Usage

const inpFuncSync1 = async () => {
return await new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, 2000);
});
};

getRuntimeCb(inpFuncSync1,(err,runtime)=>{
console.log(runtime);//2002.993833
})